package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JComboBox;
import view.MainFrame;

public class PartitionChangerListener implements ActionListener{

	
	public PartitionChangerListener(MainFrame f) {		
		frame = f;
		
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {		
		
		File name =(File) ((JComboBox<?>)arg0.getSource()).getSelectedItem();		
		frame.getCommandLineBar().setVolumeName(name.getAbsolutePath());
		frame.getMainPanel().getPrimary().getDiskContent().CreateNewView(name);
		frame.getMainPanel().getPrimary().getRelativePath().setText(name.getAbsolutePath());
		frame.getMainPanel().getPrimary().setStatusBar(name);
		frame.getMainPanel().getPrimary().setFreeSpaceInformation(String.valueOf("  [system] " + (name.getFreeSpace())/1048576) + " MB free" );
		frame.getMainPanel().getPrimary().getDiskContent().startScaning(name);
	}	
	
	

	private MainFrame frame;
	
}
